package Job;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Scanner;

public class Job02 {

	public static void main(String[] args) {
		
		Scanner s = new Scanner(System.in);
		System.out.print("请输入用户名：");
		String userName = s.next();
		System.out.print("请输入密码：");
		String passWord = s.next();
		
		Test(userName,passWord);
		
		
	}
	
	public static void Test(String userName,String passWord){
		File file = new File("user.txt");

		FileInputStream fis = null;
		
		try {
			fis = new FileInputStream(file);
			
			byte[] by = new byte[fis.available()];
			fis.read(by);
			
			String str = new String(by);
			if(str.contains(userName) && str.contains(passWord)){
				System.out.println("登陆成功");
			}else{
				System.out.println("账号或密码错误");
			}
		
			
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} finally{
			if(fis != null){
				try {
					fis.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}
	}

}
